﻿namespace ContainerVariations.Common
{
    // With much thanks to Jeremy Miller for a non-Repository sample.    
    public interface IFlattener<T>
    {
        object ToDto(T input);
    }

    public class PassthruFlattener<T> : IFlattener<T>
    {
        public object ToDto(T input)
        {
            return input;
        }
    }

    public class ContactFlattener : IFlattener<Contact>
    {
        public object ToDto(Contact input)
        {
            var dto = new ContactDto
                          {
                              FirstName = input.Name.FirstName,
                              LastName = input.Name.LastName,
                              Address1 = input.Address.Address1,
                              Address2 = input.Address.Address2,
                              City = input.Address.City,
                              State = input.Address.State,
                              Zip = input.Address.Zip,
                              Birthdate = input.Birthdate
                          };
            return dto;
        }
    }
}